package com.jlhlyby.other;

public class ClimbStairs {
    public static void main(String[] args) {
        System.out.println(new ClimbStairs().climbStairs(2));
        System.out.println(new ClimbStairs().climbStairs(3));
        System.out.println(new ClimbStairs().climbStairs(4));
    }
    public int climbStairs(int n) {
        if (n <= 0){
            return 0;
        }
        if (n == 1){
            return 1;
        }
        int first = 1;
        int second = 2;
        for (int i = 2; i<n;i++){
            int temp = second;
            second = first+second;
            first = temp;
        }
        return second;
    }
}
